package com.ss.ttm.player;

import android.app.Service;
import android.content.ComponentCallbacks;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;
import android.util.Log;

public class s extends Service {
    private static String mTempFileDir;
    private static String mCrashPath;
    private static boolean c;
    private ComponentCallbacks mComponentCallbacks;

    static {
        s.class.getSimpleName();
        s.mTempFileDir = null;
        s.mCrashPath = null;
        s.c = false;
    }

    public s() {
        this.mComponentCallbacks = null;
    }

    public static String getTempFileDir() {
        return s.mTempFileDir;
    }

    public static String getCrashPath() {
        return s.mCrashPath;
    }

    public static boolean c() {
        return s.c;
    }

    public IBinder onBind(Intent intent) {
        IBinder v0_1;
        try {
            v0_1 = new t(((Context) this));
        } catch (Exception v0) {
            v0.printStackTrace();
            v0_1 = null;
        }

        return ((IBinder) v0_1);
    }

    public void onCreate() {
        try {
            s.mTempFileDir = m.d(this);
            s.mCrashPath = m.a(18, 1) > 1 ? m.a(this) : m.b(this);
            android.support.design.a.D(s.mTempFileDir);
            TTPlayer.setTempFileDir(s.mTempFileDir);
            TTPlayer.setCrashPath(s.mCrashPath);
            TTPlayer.setIsIPPlayer(true);
            if (!m.a(4)) {
                TTPlayer.registerPlayerInfo();
            }
            s.c = TTPlayer.isError();
            Thread.UncaughtExceptionHandler defaultUncaughtExceptionHandler = Thread.getDefaultUncaughtExceptionHandler();
            if (defaultUncaughtExceptionHandler != null) {
                Log.i("ttplayer", "default ueh:" + defaultUncaughtExceptionHandler);
            }
            Thread.setDefaultUncaughtExceptionHandler(new com.ss.ttm.player.j(mCrashPath));
            this.mComponentCallbacks = Build.VERSION.SDK_INT < 14 ? new k(s.mCrashPath) : new l(s.mCrashPath);
            this.registerComponentCallbacks(this.mComponentCallbacks);
        } catch (Throwable v0) {
            s.c = true;
            v0.printStackTrace();
        }
    }

    public void onDestroy() {
        super.onDestroy();
        this.unregisterComponentCallbacks(this.mComponentCallbacks);
        android.support.design.a.log2File("onDestroy", s.mCrashPath);
    }

    public void onRebind(Intent arg1) {
        super.onRebind(arg1);
    }

    public int onStartCommand(Intent intent, int flags, int startId) {
        return START_NOT_STICKY;
    }

    public boolean onUnbind(Intent intent) {
        android.support.design.a.log2File("onUnbind", s.mCrashPath);
        return true;
    }
}

